package com.xz.knowledgeDuplication.pattern.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * 订阅主题(具体主题)
 *
 * @author 召
 * @date 2022-03-27 17:56:17
 */
public class SubscriptionSubject implements Subject{

    /**
     * 微信用户列表
     */
    private List<Observer> vxUserList = new ArrayList<Observer>();

    @Override
    public void attach(Observer observer) {
        vxUserList.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        vxUserList.remove(observer);
    }

    @Override
    public void notify(String message) {
        for (Observer observer : vxUserList) {
            observer.update(message);
        }
    }
}
